import java.util.Arrays;
import java.util.Scanner;

public class untitled {

    public static void move(char pos1, char pos3){
        System.out.print(pos1+"->"+pos3+' ');
    }

    //pos1:初始位置， pos2:中转位置， pos1:目标位置
    public static void Hanoi(int n, char pos1, char pos2, char pos3) {

        if(n == 1){
            move(pos1, pos3);
        }else{
            Hanoi(n-1,pos1, pos3, pos2);
            move(pos1, pos3);
            Hanoi(n-1,pos2, pos1, pos3);
        }
    }

    public static void main1(String[] args) {
        Hanoi(1, 'A', 'B', 'C');
        System.out.println();
        Hanoi(2, 'A', 'B', 'C');
        System.out.println();
        Hanoi(3, 'A', 'B', 'C');
    }


    public static void transform(int[] arr) {

        for (int i = 0; i < arr.length; i++) {
            arr[i] *= 2;
        }
    }

    public static void main2(String[] args) {
        int[] arr = new int[]{1, 2 ,3};
        System.out.println(Arrays.toString(arr));
        transform(arr);
        System.out.println(Arrays.toString(arr));

    }


    public static void fun(int[] arr) {

        for (int i = 0; i < arr.length; i++) {
            if(arr[i] % 2 == 0) {
                for (int j = i+1; j < arr.length; j++) {
                    int x = 0;
                    if(arr[j] % 2 != 0) {
                        x = arr[i];
                        arr[i] = arr[j];
                        arr[j]  =x;
                    }
                }
            }
        }
    }

    public static void main3(String[] args) {
        int[] arr = new int[]{1, 2 ,3, 4, 5, 6};
        System.out.println(Arrays.toString(arr));
        fun(arr);
        System.out.println(Arrays.toString(arr));

    }


    public static int found(int[] arr, int k) {
        int left = 0, right = arr.length-1;
        while(left < right){
            int a = (left+right)/2;
            if(arr[a] < k){
                left = a;
            }else if (arr[a] > k){
                right = a-1;
            }else{
                return a;
            }
        }
        return -1;
    }

    public static void main4(String[] args) {
        int[] arr = new int[]{1, 2 ,3, 4, 5, 6};
        //System.out.println(Arrays.toString(arr));
        int ret = found(arr, 5);
        System.out.println(ret);

    }



    public static void bull(int[] arr){
        for (int i = 0; i < arr.length-1; i++) {

            for (int j = 0; j < arr.length-1-i; j++) {
                if(arr[j] > arr[j+1]){
                    int x;
                    x = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = x;
                }
            }
        }
    }


    public static void main5(String[] args) {
        int[] arr = new int[]{1, 2 ,5, 9, 5, 6};
        System.out.println(Arrays.toString(arr));
        bull(arr);
        System.out.println(Arrays.toString(arr));
    }


    public static int[] abb(int[] arr, int x){

        int[] num = new int[2];
        for (int i = 0; i < arr.length; i++) {

            for (int j = i+1; j < arr.length; j++) {
                if(arr[i] + arr[j] == x){
                    num[0] = arr[i];
                    num[1] = arr[j];
                    return num;
                }
            }
        }
        return null;
    }

    public static void main(String[] args) {
        int[] nums = new int[] {2,7,11,15};
        int target = 9;
        System.out.println(Arrays.toString(nums));
        int[] ret = abb(nums, target);
        System.out.println(Arrays.toString(ret));
    }

}
